package com.keekus.common.web;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContext;
import org.springframework.security.core.context.SecurityContextHolder;

public class BaseController
  implements ApplicationContextAware
{
  private ApplicationContext ctx;

  protected Authentication getAuthentication()
  {
    SecurityContext sc = SecurityContextHolder.getContext();
    return sc.getAuthentication();
  }

  public void setApplicationContext(ApplicationContext ctx)
    throws BeansException
  {
    this.ctx = ctx;
  }

  public ApplicationContext getApplicationContext() {
    return this.ctx;
  }
}